Skip to content

ENH: Give Error message when no conda env is present #120

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

adit4443ya
Copy link
Collaborator

@adit4443ya adit4443ya commented May 17, 2025

This is just small error message as when no conda env is activated then there is no MPI or MPICH is present so user gets confused on what to do (Also we observed on call too).

(This also can be avoided I felt it to be included that's why :)

Earlier case

 aditya-trivedi   tests    err_on_conda ≢  ~1    conda deactivate
 aditya-trivedi   tests    err_on_conda ≢    FC="lfortran --cpp" ./run_tests.sh 
 aditya-trivedi   tests    err_on_conda ≢  ~1    echo $?
127
 aditya-trivedi   tests    err_on_conda ≢  ~1    conda activate mpi
 aditya-trivedi   tests    err_on_conda ≢  ~1    FC="lfortran --cpp" ./run_tests.sh 
Removing all untracked files
#################################
Using FC=lfortran --cpp compiler
Using CC=gcc compiler
################################
.
.
.

With this PR

 aditya-trivedi   tests    err_on_conda ≢  ?3 ~1    conda deactivate
 aditya-trivedi   tests    err_on_conda ≢  ?3 ~1    FC="lfortran --cpp" ./run_tests.sh 
Error: No Conda environment is active. Please activate a conda env with MPI installed.
 aditya-trivedi   tests    err_on_conda ≢  ?3 ~1    conda activate base
 aditya-trivedi   tests    err_on_conda ≢  ?3 ~1    mpiexec --version
mpiexec (OpenRTE) 4.1.6 // Some Other Implementation

Report bugs to http://www.open-mpi.org/community/help/

 aditya-trivedi   tests    err_on_conda ≢  ?3 ~1    FC="lfortran --cpp" ./run_tests.sh 
Unknown MPI implementation!

 aditya-trivedi   tests    err_on_conda ≢  ?3 ~1    conda activate pfUnit // Some Other ENV with no MPI
 aditya-trivedi   tests    err_on_conda ≢  ?3 ~1    mpiexec --version  
mpiexec: command not found // when no mpi is installed in env
 aditya-trivedi   tests    err_on_conda ≢  ?3 ~1    FC="lfortran --cpp" ./run_tests.sh 
Error: mpiexec not found. Please install MPI (OpenMPI or MPICH) via Conda or system package manager.

@adit4443ya adit4443ya requested a review from gxyd May 17, 2025 05:36
Copy link
Collaborator

@gxyd gxyd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll leave for this for @certik to give a look.

if [[ -z "$CONDA_PREFIX" ]]; then
echo -e "${RED}Error: No Conda environment is active. Please activate a conda env with MPI installed.${NC}"
exit 1
fi
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the user has global installation of MPI implementation?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This condition might cause false negative.

echo -e "${RED}Error: mpiexec not found. Please install MPI (OpenMPI or MPICH) via Conda or system package manager.${NC}"
exit 1
fi

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking for existence of ${CONDA_PREFIX}/bin/mpiexec doesn't detect MPI compilers, include paths, or libraries. We are only checking for runtime control here.

The correct approach probably will be to eventually use cmake build system for us. We've an open issue for this: #19

The current approach isn't the best one though.

Copy link
Collaborator

@gxyd gxyd May 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked pFUnit repository, the way they check the existence of MPI is using cmake's find_package using:

find_package (MPI QUIET COMPONENTS Fortran)

  if (MPI_Fortran_FOUND)
    message (STATUS "MPI enabled")
    if (ENABLE_MPI_F08)
      if (NOT MPI_Fortran_HAVE_F08_MODULE)
        message (FATAL_ERROR "MPI F08 module requested but not available")
      else()
        message (STATUS "MPI F08 module enabled")
      endif()
    endif()
  else ()
    message (STATUS "MPI not found; building without MPI")
  endif()

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh YEs i Didn't see that CMAKE issue Thanks for mentioning it.
We can avoid this approach if not needed.

@gxyd gxyd requested a review from certik May 17, 2025 11:45
@adit4443ya adit4443ya marked this pull request as draft May 18, 2025 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants